package com.mccken.demo.io.netty.server;

import com.mccken.demo.io.netty.codec.MyDecoder;
import com.mccken.demo.io.netty.codec.MyEncoder;
import com.mccken.demo.io.netty.support.RpcRequest;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2022-04-30 18:42
 **/
public class ServerInitializer extends ChannelInitializer<SocketChannel> {
	
	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		ch.pipeline()
				.addLast(new MyDecoder(RpcRequest.class)) //解码器，需要解码的对象是RpcRequest
				.addLast(new MyEncoder()) //编码器，用于数据的响应
				.addLast(new ServerHandler()); //自定义逻辑
	}
}
